﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace WindowsApplication1
{
    public partial class F_YPHWMGL : Form
    {
        public F_YPHWMGL()
        {
            InitializeComponent();
            show2();
        }

        SqlConnection conn;
        SqlCommand com;
        DataSet ds;
        SqlDataAdapter da;
        //SqlDataReader dr;

        public void show2()
        {
            conn = new SqlConnection();
            conn.ConnectionString = SQL.getCon;
            com = new SqlCommand();
            com.CommandText = "select bm 药品编码,mc 药品名称,gg 药品规格,yply 药品来源,yplx 药品类型,yphwm 药品货位码 from ypgg ";
            ds = new DataSet();
            da = new SqlDataAdapter();
            com.Connection = conn;
            da.SelectCommand = com;
            da.Fill(ds, "yptx");
            dataGridView1.DataSource = ds.Tables["yptx"];
        }

        public void show1()
        {
            conn = new SqlConnection();
            conn.ConnectionString = SQL.getCon;
            com = new SqlCommand();
            com.CommandText = "select bm 药品编码,mc 药品名称,gg 药品规格,yply 药品来源,yplx 药品类型,yphwm 药品货位码 from ypgg where mc like '" +textBox1 .Text +"%'" ;
            ds = new DataSet();
            da = new SqlDataAdapter();
            com.Connection = conn;
            da.SelectCommand = com;
            da.Fill(ds, "yptx");
            dataGridView1.DataSource = ds.Tables["yptx"];
        }

      
        private void F_YPHWMGL_Load(object sender, EventArgs e)
        {

            //this.reportViewer1.RefreshReport();
        }

        private void Quit_bt_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            dataGridView1.Columns[0].ReadOnly = true;
            dataGridView1.Columns[1].ReadOnly = true;
            dataGridView1.Columns[2].ReadOnly = true;
            dataGridView1.Columns[3].ReadOnly = true;
            dataGridView1.Columns[4].ReadOnly = true;
            dataGridView1.Columns[5].ReadOnly = false;
        }

        private void Check_bt_Click(object sender, EventArgs e)
        {
            show1();
        }

        private void Save_bt_Click(object sender, EventArgs e)
        {

        }
    }
}